<%--
 *  File:    MonthStockData.jsp
 *  @Author: JackYin
 *  Date:    2011.1.11

 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%
String strModuleName = "COM";
String privilegeCode = "A0111";
String strTableName = "v_zylmonthstockdatasummary";
String contextPath = request.getContextPath();
%>
<%@ include file="/inc/CommonHeader.inc" %>
<%@ include file="/inc/OvalLocationDefault.inc" %>
<%@ include file="/rpt/ReportURL.inc" %>
<html>
<head>
<title>MonthStockData</title>
<PageFlow:CheckPageFlow pageName="p_monthstockdatasummary"/>
<%

HashMap userinfo = (HashMap)session.getAttribute("userinfo");
String  issalesman = (String) userinfo.get("issalesman");
String flag = (String)pageContext.getAttribute("flag");

%>
<%@ include file="/inc/CatchError.inc" %>
<%@ include file="/inc/SumDiv.inc" %>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/SummaryDivision.js"></script>
<script language="JavaScript">
//xuanze
function popDealer() {
	  opt = "dealer";
	  var status = "height=450, width=600, top=100, left=100, toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no";
			var url = "PathOrgSelect.jsp?o_thread=" + Math.random();
			url += "&globalpccode=112,113,114,117";
			if (typeof popwindow != 'undefined') popwindow.close();
			popwindow = window.open(url, "newwindow", status);
	}
	
	function popCustomer() {
	  opt = "customer";
	  var status = "height=450, width=600, top=100, left=100, toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no";
			var url = "PathOrgSelect.jsp?o_thread=" + Math.random();
			url += "&orgglobalpccodes=99,112,117";
			
			if (typeof popwindow != 'undefined') popwindow.close();
			popwindow = window.open(url, "newwindow", status);
	}
	function page_setOrg(id, name, code) {
	  if(opt == "dealer"){
	  	cform.dealerid.value=id;
	  	cform.dealercode.value = code;
	  	cform.dealername.value = name;
	  }
	  if(opt == "customer"){
	  	cform.customerid.value=id;
	  	cform.customercode.value = code;
	  	cform.customername.value = name;
	  }	
	  opt = "";
	  if (popwindow != null)
	    popwindow.close();
	}


//salesman
function popRep() {
	var regionid=cform.regionid.value;
	var proviceofficecode = cform.proviceofficelist.value;
	var businessareacode = cform.businessarealist.value;
	//alert(regionid+"|"+proviceofficecode+"|"+businessareacode+"|");
	var status = "height=400, width=600, top=100, left=100, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no";
	var url = "<%=contextPath%>/tdr/dataverify/SalesPopWindow.jsp?<%= OvalTools.randomURL() %>&regionid="+regionid+"&proviceofficecode="+proviceofficecode+"&businessareacode="+businessareacode;
	popwindow = window.open(url, "newwindow", status);
  }

function SetSalesMan(id,code,name){
	cform.userids.value=id;
	cform.employeecode.value=code;
	cform.employeename.value=name;
}

function page_actionfun(){
if(isNullChecked(cform.historyofmonthinventoryid)) 
  {
    alert('<%=message.getMessageDesc("PLEASE_SELECT")%>');
    return;
  }
  if(!confirm("<%=message.getMessageDesc("ZYL_TDR_YESPASS")%>"))return;
  cform.actionname.value = "checkpass";
  cform.target = "_self";
  isRunning = true;
  document.cform.submit();
		
}

//getbusinessarea
function page_getpriviceoffice(){
	var objdeptcode=eval("cform.regionid");
	if (objdeptcode==""){
	    return;
	}
	var  datahandler = new  DataHandler();
	datahandler.add_params("regionid" , objdeptcode.value , "Integer");
	datahandler.getResultFromVector("resultproviceoffice","proviceofficename","proviceofficecode","cform.proviceofficelist");
	datahandler.add_job("j_yorndealersummary");
	datahandler.runDataHandler();
  }

function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  if(!editform) return;
  editform.action = "MonthStockData.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}

function page_getbusinessarea(){
	var regionid = cform.regionid.value;
	var objdeptcode = eval("cform.proviceofficelist");
	if (objdeptcode==""){
	    return;
	}
	var  datahandler = new  DataHandler();
	datahandler.add_params("regionid" , regionid, "Integer");
	datahandler.add_params("proviceofficelist" , objdeptcode.value , "String");
	datahandler.getResultFromVector("resultbusinessarea","businessareaname","businessareacode","cform.businessarealist");
	datahandler.add_job("j_yorndealersummary");
	datahandler.runDataHandler();
 }
 
function page_allcheckselect(){
	var allcheck = cform.allcheck.checked;
	var alldatafile = document.getElementsByName('historyofmonthinventoryid');
	var length = alldatafile.length;
	if(allcheck){
		for(var i = 0 ; i < length;i++){
			if(!alldatafile[i].disabled)
			alldatafile[i].checked = true;
		}
	}else{
		for(var i = 0 ; i < length;i++){
			alldatafile[i].checked = false;
		}	
	}
}
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="overflow: auto">
<iframe id="reloadHandler" name="reloadHandler" style="display:none"></iframe>
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher">
  <input type="hidden" name="pagename" value="p_monthstockdatasummary">
  <input type="hidden" name="actionname">
  <custom:hidden property="userid" name="userinfo" scope="session"></custom:hidden>
<%@ include file="/inc/PageLocation.inc" %>
<table width="100%" cellspacing="0" border="0" cellpadding="0">
  <tr>
    <td>
      <table width="100%" border="0" cellspacing="0">
        <tr>
          <td class="summary_top" width="10%" colspan="3"></td>
        </tr>
        <%@ include file="/inc/SummarySearch.inc" %>
      </table>
    </td>
  </tr>
  <tr>
    <td>
      <table width="350" border="0" cellspacing="0" >
		<tr>
	        <td><%= label.getLabelName("L_Partner") + label.getLabelName("L_Colon") %></td>
	        <td>
	            <custom:text property="dealercode" size="10" readonly="true"/>
	            <a onclick="javascript:popDealer();"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
	            <custom:text property="dealername" readonly="true" size="30"/>
	            <custom:hidden property="dealerid" />
	        </td>
		</tr>
	  </table>
    </td>
  </tr>
  <tr>
    <td>
		<table width="1000" border="0" cellspacing="0" >
        		<% 
	                if("Y".equals(issalesman)){
	            %> 
	            <tr>
	               <td style="width:40px;">&nbsp;</td><td style="width:150px;">&nbsp;</td>
	               <td style="width:40px;">&nbsp;</td><td style="width:150px;">&nbsp;</td>
	               <td style="width:40px;">&nbsp;</td><td style="width:150px;">&nbsp;</td>
	               <td style="width:60px;">&nbsp;</td><td style="width:150px;">&nbsp;</td>
	               <td style="width:60px;">&nbsp;</td><td style="width:150px;">&nbsp;</td>
	               </tr>
	                <%}else{ %>
        	    <tr>
                <td style="width:40px;" class="td_right"><%=label.getLabelName("L_Businessarea") +  label.getLabelName("L_Colon") %></td>
        	  	<td style="width:150px;" class="td_left"><custom:select property="regionid" optionInnerTextKey="regionname" optionsName="resultregion" optionValueKey="regionid" style="width:150px;"  defaultValue="-------ALL-------" defaultValueCost=""/></td>
        	    <td style="width:40px;" class="td_right"><%=label.getLabelName("L_ProvinceOffice") +  label.getLabelName("L_Colon") %></td>
				<td style="width:150px;" class="td_left">
				<custom:select property="proviceofficelist" optionInnerTextKey="proviceofficename" optionsName="resultproviceoffice" optionValueKey="proviceofficelist" style="width:150px;" defaultValue="-------ALL-------" defaultValueCost="" /></td>
			    <td style="width:60px;" class="td_right"><%=label.getLabelName("L_BusinessAreaName") +  label.getLabelName("L_Colon") %></td>
				<td style="width:150px;" class="td_left">
				<custom:select property="businessarealist" optionInnerTextKey="businessareaname" optionsName="resultbusinessarea" optionValueKey="businessarealist" style="width:170px;" defaultValue="---------ALL---------" defaultValueCost=""/> </td>
        	     <td style="width:60px;" class="td_right"><%=label.getLabelName("L_BusinessContact") +  label.getLabelName("L_Colon") %></td>
				<td style="width:150px;">
			  <custom:text property="employeename" size="20" readonly="true" style="border:1px #7F9DB9 solid;"/>
			  <a onClick="javascript:popRep();"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a> 
			  <custom:hidden property="userids"/>
			  <custom:hidden property="employeecode"/>
		       </td>
				<td style="20px;"><button type="reset" class="button1" name="re" value="clear"  style="width:60"><%=label.getLabelName("L_Clear") %></button></td>
			<%}%>
        	</tr>
          </table>
    </td>
  </tr>
    <tr>
        <td>
          <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
  
<%
    ArrayList titleTdArray = new ArrayList();
    //titleTdArray.add(new TD("22","&nbsp;"));
    titleTdArray.add(new TD("22","<input type=\"checkbox\" class='normalradio' name='allcheck' onclick='page_allcheckselect()'"));
    titleTdArray.add(new TitleTD("90","L_Date") );
    titleTdArray.add(new TitleTD("170","L_PartCodeC"));
    titleTdArray.add(new TitleTD("120","L_PartNameN"));
    titleTdArray.add(new TitleTD("100","L_ProdCode"));
    titleTdArray.add(new TitleTD("100","L_ProdName"));
	titleTdArray.add(new TitleTD("100","L_Quantity"));
	titleTdArray.add(new TitleTD("100","L_Status"));
%>
    <custom:titletr styleClass="deepblue-left" tdArray="<%=titleTdArray%>" />
  
<%
     ArrayList detailTdArray = new ArrayList();
     detailTdArray.add(new CheckBoxTD("historyofmonthinventoryid"));
     detailTdArray.add(new WriteTD("startdate"));
     detailTdArray.add(new WriteTD("orgcode"));
     detailTdArray.add(new WriteTD("orgname"));
     detailTdArray.add(new WriteTD("itemcode"));
     detailTdArray.add(new WriteTD("itemnamecn"));
	 detailTdArray.add(new WriteTD("qtyall"));
	 detailTdArray.add(new WriteTD("statusname"));
     
     ArrayList hiddenArray = new ArrayList();
     hiddenArray.add(new HiddenInput("orgcode",true));
     hiddenArray.add(new HiddenInput("itemcode",true));
     hiddenArray.add(new HiddenInput("qtyall",true));
	 hiddenArray.add(new HiddenInput("status",true));

     %>
      <custom:iteratetr tdArray="<%=detailTdArray%>" hiddenArray="<%=hiddenArray%>"  dataSource="searchresults"/>
        <tr> 
	          <td colspan="6" style="text-align:right"><%=label.getLabelName("L_PageSum") +  label.getLabelName("L_Colon")%></td>
				<td class="red"><b><custom:write property="sumqtyall" nbsp="true"/></b></td>
				<td>&nbsp;</td>	
	        </tr>
	        <tr> 
	          <td colspan="6" style="text-align:right"><%=label.getLabelName("L_TotalSum") +  label.getLabelName("L_Colon")%></td>
				<td class="red"><b><custom:write name="sumhash" property="qty" dataType="number" dataFormatName="qtyviewformat" nbsp="true"/></b></td>
			<td>&nbsp;</td>
          <%@ include file="/inc/SummaryAction.inc" %>
        </tr>
      </table>
           <table width="100%" cellspacing="0" cellpadding="0">
            <tr><td class="summary_top"></td></tr>
            <tr>
              <td class="td_center">
                   <td class="td_center">
              	<% if(pageContext.getAttribute("searchresults")!=null){%>
              	<a onclick="page_excel();"><custom:button type="1" label="L_ExcelE" imgsrc="Modify.gif" border="0" style="width:100"/></a>&nbsp;&nbsp;<a onclick="page_actionfun();"><custom:button type="1" label="L_CheckPass" imgsrc="Modify.gif" border="0" style="width:100"/></a>
            <%} %>
              </td>
            </tr>
          </table>
    </td>
  </tr>
 </table>
 </form>
<script>
for(i=0;i<cform.historyofmonthinventoryid.length;i++){
	if(eval('cform.status'+i).value == "41"){
		cform.historyofmonthinventoryid[i].disabled=true;
	}
}
</script>
</body>
</html>